package pacman.state;

import org.newdawn.slick.Color;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Input;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.state.BasicGameState;
import org.newdawn.slick.state.StateBasedGame;
import org.newdawn.slick.state.transition.FadeInTransition;
import org.newdawn.slick.state.transition.FadeOutTransition;

import pacman.base.Score;

public class LevelWin extends BasicGameState {

    public static final int ID = 4;
    private StateBasedGame sbg;
    private GameContainer gc;

    public void init(GameContainer gc, StateBasedGame sbg) throws SlickException {
		this.sbg = sbg;
		this.gc = gc;
    }

    public void render(GameContainer gc, StateBasedGame sbg, Graphics g) throws SlickException {
		g.drawString("Score :" + Score.getFinalScore(), 20, 20);
		g.drawString("Level WIN! Press ENTER to continue", 100, 100);
    }

    public void update(GameContainer gc, StateBasedGame sbg, int delta) throws SlickException {
    }
    
    public void keyReleased(int key, char c) {
		if (key == Input.KEY_ENTER) sbg.enterState(Game.ID, new FadeOutTransition(Color.black), new FadeInTransition(Color.black));
		if (key == Input.KEY_F2) {
		    try {
				if (!gc.isFullscreen())  gc.setFullscreen(true);
				else  gc.setFullscreen(false);
		    } catch (Exception e) {
		    	System.out.println(e.getMessage());
		    }
		}
    }
    
    @Override
    public int getID() {
    	return ID;
    }
}
